package com.zxhysy.log.test.controller;

import com.zxhysy.log.annotation.Log;
import com.zxhysy.log.annotation.LogConfig;
import com.zxhysy.log.annotation.LogIgnore;
import com.zxhysy.log.test.entity.TestIgnoreLog;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zhangxinhong
 * @since 2021/9/6 9:31
 */
@LogConfig(bizType = "用户管理", logType = "操作日志")
@RestController
@RequestMapping("/api")
public class ApiController {

    @Log(success = "hello1")
    @GetMapping("/hello")
    public String hello() {
        return "he1llo";
    }

    @Log(success = "hello2")
    @GetMapping("/hello2")
    public String hello2(String userName) {
        return "hello2:" + userName;
    }

    @Log(success = "hello3")
    @GetMapping("/hello3")
    public Map<String, String> hello3(String userName) {
        Map<String, String> map = new HashMap<>(16);
        map.put("hello", userName);
        return map;
    }

    @GetMapping("/hello55")
    public String hello55() {
        return "hello55";
    }

    @Log(success = "hello4")
    @GetMapping("/hello4")
    public Map<String, String> hello4(String userName, String password) {
        Map<String, String> map = new HashMap<>(16);
        map.put("hello", userName);
        map.put("password", password);
        return map;
    }

    @Log(success = "hello5")
    @GetMapping("/hello5")
    public Map<String, Object> hello5(@RequestParam Map<String, Object> params) {
        return params;
    }

    @Log(success = "hello6")
    @PostMapping("/hello6")
    public Map<String, String> hello6(@RequestBody Map<String, String> params) {
        return params;
    }

    @Log(success = "hello7", ignore = "name")
    @GetMapping("/hello7")
    public String test(@LogIgnore String id, String name) {
        return id + name;
    }
    @Log(success = "hello8")
    @GetMapping("/hello8")
    public String test2(@LogIgnore String id, String name) {
        return id + name;
    }

    @Log(success = "hello9")
    @PostMapping("/hello9")
    public TestIgnoreLog test3(@RequestBody TestIgnoreLog test) {
        return test;
    }
}
